package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbItemMapper;
import com.dongdongshop.pojo.TbItem;
import com.dongdongshop.pojo.TbItemExample;
import com.dongdongshop.service.TbItemService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DubboService
public class TbItemServiceImpl implements TbItemService {
    @Autowired
    private TbItemMapper itemMapper;

    @Override
    public List<TbItem> selectAll() {
        return itemMapper.selectByExample(null);
    }

    @Override
    public TbItem selectByItemId(String itemId) {
        return itemMapper.selectByPrimaryKey(Long.valueOf(itemId));
    }

    @Override
    public List<TbItem> selectItemById(Long id) {
        TbItemExample example = new TbItemExample();
        TbItemExample.Criteria criteria = example.createCriteria();
        criteria.andGoodsIdEqualTo(id);
        return itemMapper.selectByExample(example);
    }
}
